import { SyncThreeWithCesium } from '../../components/cesium-three/SyncThreeWithCesium.js'
import { on, CESIUM_VIEWER_INITIALIZATION } from '../../utils/EventBus.js'
import { loadMapLayers } from './loadMapLayers.js'
import { sceneName } from '../three-scene/index.js'
// import { getSceneByName } from '../../components/three/ThreeScene.vue'
import { waitUntilValueExist } from '../../utils/unsorted.js'
import { Group } from '@tweenjs/tween.js'
import { SyncCesiumWithThree } from '../../components/cesium-three/SyncCesiumWithThree.js'

import { MyMapControls } from '../../components/three/controls/MyMapControls.js'

// on(CESIUM_VIEWER_INITIALIZATION, ({ detail: viewer }) => {
//     viewer.scene.globe.depthTestAgainstTerrain = true

//     waitUntilValueExist(() => getSceneByName(sceneName)).then((scene) => {
//         SyncThreeWithCesium.instnace = new SyncThreeWithCesium({
//             threeCamera: scene.my.camera,
//             cesiumCamera: viewer.camera,
//         })
//     })

//     viewer.clock.onTick.addEventListener((clock) => {
//         tweenGroupAlongCesium.update()
//         if (SyncCesiumWithThree.instance && !MyMapControls.instance?.enabled) {
//             SyncThreeWithCesium.instnace.sync()
//         }
//     })

//     // loadMapLayers()
// })

export const tweenGroupAlongCesium = new Group()
